package classes.shapes
{
	import classes.fillstyle.FillStyle;
	import classes.math.Math2D;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.GlowFilter;
	import flash.geom.Point;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.utils.clearInterval;
	import flash.utils.setInterval;
	
	public class LabelArc extends Arc
	{
		private var _label:String = "";
		private var _labelTF:TextField = new TextField();
		private var _labelCon:Sprite = new Sprite();
		
		public var actived:Boolean = false;
		
		public function LabelArc(startAngle:Number, endAngle:Number, minRadius:Number, maxRadius:Number, lineStyle:FillStyle=null, fillStyle:FillStyle=null, label:String = "Label")
		{
			super(startAngle, endAngle, minRadius, maxRadius, lineStyle, fillStyle);
			this._label = label;
			
			var format:TextFormat = new TextFormat();
			format.size = 30;
			format.color = 0xffffff;
			
			_labelTF.defaultTextFormat = format;
			_labelTF.autoSize = TextFieldAutoSize.LEFT;
			_labelTF.text = _label;
			_labelTF.selectable = false;
			_labelTF.rotationZ = 0;
			_labelTF.filters = [new GlowFilter(0x000000, 0.5, 10, 10)];
			_labelCon.addChild(_labelTF);
			updateLabelPos();
			addChild(_labelCon);
		}
		
		public function set label(value:String):void
		{
			this._labelTF.text = value;
			updateLabelPos();
		}
		
		private function updateLabelPos():void
		{
			_labelTF.x = -_labelTF.textWidth/2;
			_labelTF.y = -_labelTF.textHeight/2;
			
			var midRadius:Number = (minRadius + maxRadius)/2;
			var centerAngle:Number = (startAngle + endAngle)/2;
			
			var center:Point = Math2D.rotatePoint(new Point(midRadius, 0), new Point(), centerAngle);
			_labelCon.x = center.x;
			_labelCon.y = center.y;
			_labelCon.rotation = centerAngle + 90;
		}
		
		
	}
}

















